package pl.streamsoft.test.currency_view;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages = { "pl.streamsoft.test.currency_view.storage",
		"pl.streamsoft.test.currency_view",
		"pl.streamsoft.test.currency_buisness" })
public class App {

	public static void main(String[] argv) {
		final ApplicationContext context = new AnnotationConfigApplicationContext(
				App.class);
		MainView mainView = (MainView) context.getBean(MainView.class);
		mainView.initComponents();
		mainView.setVisible(true);

		mainView.addWindowListener(new WindowListener() {

			@Override
			public void windowOpened(WindowEvent e) {

			}

			@Override
			public void windowIconified(WindowEvent e) {

			}

			@Override
			public void windowDeiconified(WindowEvent e) {

			}

			@Override
			public void windowDeactivated(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowClosing(WindowEvent e) {
				((AnnotationConfigApplicationContext) context).close();

			}

			@Override
			public void windowClosed(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowActivated(WindowEvent e) {
				// TODO Auto-generated method stub

			}
		});

	}
}